{% extends "grappelli/templates/admin/change_form.html" %}
{% load i18n admin_modify adminmedia %}

{% block stylesheets %}
   {{ block.super }}
   <style type="text/css">
      input[type=number]:invalid { background-color: #ff9ca3; }
   </style>
{% endblock %}

<!-- CONTENT SWORD override -->
{% block content %}
  <div class="container-flexible">
    <div class="form-container">
      <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% csrf_token %}{% block form_top %}{% endblock %} 
        <div>
          <!-- Popup Hidden Field -->
          {% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
          
          <!-- Submit-Row -->
          {% if save_on_top %}{% submit_row %}{% endif %}
          
          <!-- Errors -->
          {% if errors %}
            <p class="errornote">{% blocktrans count errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}</p>
            <ul class="errorlist">{% for error in adminform.form.non_field_errors %}<li>{{ error }}</li>{% endfor %}</ul>
          {% endif %}
          
          <!-- Fieldsets -->
          {% for fieldset in adminform %}
            {% include "admin/includes/fieldset.html" %}
          {% endfor %}
          {% include "admin/includes/custom_field_fieldset.html" with custom_form=custom_form %}
          
          {% block after_field_sets %}{% endblock %}
          
          <!-- Inlines -->
          {% for inline_admin_formset in inline_admin_formsets %}
            {% include inline_admin_formset.opts.template %}
          {% endfor %}
          
          {% block after_related_objects %}{% endblock %}
          
          <!-- Submit-Row -->
          {% submit_row %}
          
          {% if adminform and add %}
            {% block extrahead %}
              <script type="text/javascript">
                (function($){
                  $(function(){
                    try {
                      // focus on first form-field
                      $("#{{ adminform.first_field.auto_id }}, #{{ adminform.first_field.auto_id }}_0")
                      .eq(0).focus();
                    } catch(e) {}
                  });
                }(django.jQuery));
              </script>
            {% endblock %}
          {% endif %}
          
          <!-- JS for prepopulated fields -->
          {% prepopulated_fields_js %}
          
        </div>
      </form>
    </div>
  </div>
{% endblock %}